Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @scope decorator #1998

Merged
merged 15 commits into from
Jan 3, 2025
Merged

Add @scope decorator #1998

merged 15 commits into from
Jan 3, 2025

Conversation

live1206
Copy link
Member

@live1206 live1206 commented Dec 18, 2024

Resolves #964

The scope parameter of @scope decorator is not working as the normal decorator.
For a normal decorator, we need to get the decorator value from state map based on the scope and the current emitter name. If the value hit from the state map with current emitter name, it's a positive case, if not hit, it's a negative case.

@clientName("Renamed", csharp)
model A;

With the normal decorator scope handling, if the decorator is absent it is a negative case. For the case below, we don't need to handle @clientname decorator, it is a negative case.

model A;

But for @scope decorator, when it is absent, it means AllScopes, which is also a positive case. For below two cases, python emitter should include this operation, both of them are positive case.

op func: void

and

@scope("!csharp")
op func: void

For incremental applying, the mechanism should be similar to the normal decorator scope handling.

  • for the same scope, the later decorator value wins regardless it's defined with normal scope or scope negation

@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Dec 18, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 18, 2024

All changed packages have been documented.

  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-client-generator-core - feature ✏️

Add @scope decorator to define the language scope for operation

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

@live1206 live1206 added this pull request to the merge queue Jan 3, 2025
Merged via the queue into Azure:main with commit 9d16af1 Jan 3, 2025
23 checks passed
@live1206 live1206 deleted the scope-decorator branch January 3, 2025 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TCGC] Need a way to remove operation from TCGC
3 participants